<!DOCTYPE html>
<html>
    <head>
        <script src="js/vue.js"></script>
        <script src="js/vuex.js"></script>
    </head>
    <body>
        <div id="app">
            <button @click="paramM">传递参数</button>
            <p>{{this.$store.state.param}}</p>
        </div>
        <script>
            var store = new Vuex.Store({
                state : {
                    param : '1'
                },
                mutations : {
                    receive(state,param1) {
                        console.log(param1);
                        state.param = param1;
                    }
                },
                actions : {
                    param(context,param2) {
                        // context.commit('receive',param2)
                        context.commit({type:'receive',name:param2})
                    }
                }
            })

            var vm = new Vue({
                el : '#app',
                store,
                methods : {
                    paramM() {
                        this.$store.dispatch('param','我是需要传递的参数2');
                    }
                }
            })

        </script>
    </body>
</html>